﻿using System.Web.Mvc;
using System.Linq;
using KaytechSoftware.Cms.App.Areas.Content.Models;
using KaytechSoftware.Cms.Services.Interfaces;
using KaytechSoftware.Cms.Services.Interfaces.Entity;

namespace KaytechSoftware.Cms.App.Areas.Content.Controllers
{
    public class NewsController : ContentController
    {
        private readonly INewsService _newsService;

        public NewsController(INewsService newsService)
        {
            _newsService = newsService;
        }

        public override PartialViewResult Content(long id)
        {
            var news = _newsService.GetAllForPage(id);
            var model = new NewsFeedModel();
            model.Items = news.Select(n => new NewsArticleModel { Id = n.Id, Title = n.Title, Body = n.Body, Order = n.Order }).ToList();

            return PartialView(model);
        }
    }
}
